package com.antler.smt.portal.service.impl;

import com.antler.smt.entity.OrderCommentEntity;
import com.antler.smt.entity.OrderCommentPictureEntity;
import com.antler.smt.entity.OrderEntity;
import com.antler.smt.portal.mapper.OrderCommentEntityMapper;
import com.antler.smt.portal.mapper.OrderCommentPictureEntityMapper;
import com.antler.smt.portal.mapper.OrderCommentPictureInfoMapper;
import com.antler.smt.portal.mapper.OrderEntityMapper;
import com.antler.smt.response.base.Result;
import com.antler.smt.service.portal.OrderCommentPictureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhangyi
 * @date 2018/5/12 14:42
 */
@Service
public class OrderCommentPictureServiceImpl implements OrderCommentPictureService {


    @Autowired
    private OrderCommentEntityMapper orderCommentEntityMapper;

    @Autowired
    private OrderCommentPictureInfoMapper orderCommentPictureInfoMapper;

    /**
     *  显示订单评价图片信息
     *
     * @param orderCommentId
     * @return
     */
    @Override
    public Result showOrderCommentImg(Long orderCommentId) {
        Result result = null;

        OrderCommentEntity orderCommentEntity = orderCommentEntityMapper.selectByPrimaryKey(orderCommentId);

        String memberCommentImg = orderCommentPictureInfoMapper.getMemberCommentImg(orderCommentEntity.getId());

        List commentList = new ArrayList();
        if(memberCommentImg != null){
            commentList.add(memberCommentImg);
        }
        //评价信息图片列表
         commentList.add(orderCommentPictureInfoMapper.getCommentList(orderCommentId));

        result = new Result(commentList);

        return result;
    }
}
